import 'package:flutter_admin/utils/utils.dart';

class PurchaseQualificationsFile {

  String? id;
  String? suppliercode;
  String? qualificationsname;
  String? issuingauthority;
  String? issuingdate;
  String? expirydate;
  String? filename;
  String? remark;
  String? createUid;
  String? createName;
  String? createDate;
  String? writeUid;
  String? writeDate;
  String? content;
  String? directoryId;

  PurchaseQualificationsFile({
    this.id,
    this.suppliercode,
    this.qualificationsname,
    this.issuingauthority,
    this.issuingdate,
    this.expirydate,
    this.filename,
    this.remark,
    this.createUid,
    this.createName,
    this.createDate,
    this.writeUid,
    this.writeDate,
    this.directoryId,
    this.content,
  });

  PurchaseQualificationsFile copyWith({
    String? id,
    String? suppliercode,
    String? qualificationsname,
    String? issuingauthority,
    String? issuingdate,
    String? expirydate,
    String? filename,
    String? remark,
    String? createUid,
    String? createDate,
    String? writeUid,
    String? writeDate,
  }) {
    return new PurchaseQualificationsFile(
      id: id ?? this.id,
      suppliercode: suppliercode ?? this.suppliercode,
      qualificationsname: qualificationsname ?? this.qualificationsname,
      issuingauthority: issuingauthority ?? this.issuingauthority,
      issuingdate: issuingdate ?? this.issuingdate,
      expirydate: expirydate ?? this.expirydate,
      filename: filename ?? this.filename,
      remark: remark ?? this.remark,
      createUid: createUid ?? this.createUid,
      createDate: createDate ?? this.createDate,
      writeUid: writeUid ?? this.writeUid,
      writeDate: writeDate ?? this.writeDate,
    );
  }

  @override
  String toString() {
    return '''PurchaseQualificationsFile{
      id: id,
      suppliercode: suppliercode,
      qualificationsname: qualificationsname,
      issuingauthority: issuingauthority,
      issuingdate: issuingdate,
      expirydate: expirydate,
      filename: filename,
      remark: remark,
      createUid: createUid,
      createDate: createDate,
      writeUid: writeUid,
      writeDate: writeDate,
    }''';
  }

  @override
  bool operator ==(Object other) => identical(this, other) || (
      other is PurchaseQualificationsFile &&
          runtimeType == other.runtimeType
          && id== other.id
          && suppliercode== other.suppliercode
          && qualificationsname== other.qualificationsname
          && issuingauthority== other.issuingauthority
          && issuingdate== other.issuingdate
          && expirydate== other.expirydate
          && filename== other.filename
          && remark== other.remark
          && createUid== other.createUid
          && createDate== other.createDate
          && writeUid== other.writeUid
          && writeDate== other.writeDate
   );


  factory PurchaseQualificationsFile.fromMap(Map<String, dynamic> map) {
    return new PurchaseQualificationsFile(
      id: map['id']!=false?map['id'].toString() as String?:"",
      suppliercode: map['suppliercode']!=false?map['suppliercode'].toString() as String?:"",
      qualificationsname: map['qualificationsname']!=false?map['qualificationsname'].toString() as String?:"",
      issuingauthority: map['issuingauthority']!=false?map['issuingauthority'].toString() as String?:"",
      issuingdate: map['issuingdate']!=false?map['issuingdate'].toString() as String?:"",
      expirydate: map['expirydate']!=false?map['expirydate'].toString() as String?:"",
      filename: map['filename']!=false?map['filename'].toString() as String?:"",
      remark: map['remark']!=false?map['remark'].toString() as String?:"",
      createUid: map['create_uid'][0]!=false?map['create_uid'][0].toString() as String?:"",
      createName: map['create_uid'][1]!=false?map['create_uid'][1].toString() as String?:"",
      createDate: map['create_date']!=false?map['create_date'].toString() as String?:"",
      writeUid: map['write_uid']!=false?map['write_uid'].toString() as String?:"",
      writeDate: map['write_date']!=false?map['write_date'].toString() as String?:"",
    );
  }

  Map<String, dynamic> toMap() {
    // ignore: unnecessary_cast
    return {
      'id': this.id,
      'suppliercode': this.suppliercode,
      'qualificationsname': this.qualificationsname,
      'issuingauthority': this.issuingauthority,
      'issuingdate': this.issuingdate,
      'expirydate': this.expirydate,
      'filename': this.filename,
      'remark': this.remark,
      'createUid': this.createUid,
      'createDate': this.createDate,
      'writeUid': this.writeUid,
      'writeDate': this.writeDate,
    } as Map<String, dynamic>;
  }

  List toDomainList() {
    List list = [
      if (this.suppliercode != null && this.suppliercode != '')
        ['suppliercode', '=', suppliercode],
    ];
    return list;
  }

  Map<String, dynamic> toOdooMap() {
    // ignore: unnecessary_cast
    return {
      'id': this.id,
      'suppliercode': this.suppliercode,
      'qualificationsname': this.qualificationsname,
      'issuingauthority': this.issuingauthority,
      'issuingdate': this.issuingdate,
      'expirydate': this.expirydate,
      'filename': this.filename,
      'remark': this.remark,
      'create_uid': this.createUid,
      'create_date': this.createDate,
      'write_uid': this.writeUid,
      'write_date': this.writeDate,
      'content': this.content,
      'directory_id': int.parse(this.directoryId!),
    } as Map<String, dynamic>;
  }

//</editor-fold>

}